package com.ayh.campusfun.vo;

import cn.hutool.core.bean.BeanUtil;
import com.ayh.campusfun.common.PageResult;
import com.ayh.campusfun.entity.TopicOrFunClassify;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ayh
 * @create 2021/3/30 14:50
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class FunClassifyVO {

    private Long id;
    private String classifyName;
    private Integer classifyType;
    private String classifyKey;
    PageResult funSharePageResult;

    public static List<FunClassifyVO> buildList(List<TopicOrFunClassify> topicOrFunClassifies,PageResult funSharePageResult){
        return topicOrFunClassifies.stream().map(v -> {
            FunClassifyVO funClassifyVO = new FunClassifyVO();
            BeanUtil.copyProperties(v,funClassifyVO);
            if(v.getId()==1) {
                funClassifyVO.setFunSharePageResult(funSharePageResult);
            }
            return funClassifyVO;
        }).collect(Collectors.toList());
    }
}
